var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')

module.exports = {
    devtool: "eval-source-map",
    entry: {
        app: __dirname + "/src/main.js"
    },
    output: {
        path: __dirname + '/dist',
        filename: "js/[name].js",
        // publicPath: 'dist/'
    },
    devServer: {
        contentBase: "./dist",
        historyApiFallback: true,
        inline: true,
        // hot: true
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                loader: "babel-loader",
            },
            {
                test: /\.scss$/i,
                use:ExtractTextPlugin.extract({
                    fallback:'style-loader',
                    use:['css-loader','sass-loader'],
                    publicPath: '../'
                })
            },
            {
                test: /\.(gif|jpg|png|woff|svg|eot|ttf|ico)/,
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 3145728,
                        name: 'images/[hash:8].[name].[ext]'
                    }
                }]
            },
            {
                test: /\.html$/,
                loader: 'html-withimg-loader'
            }
        ]
    },
    plugins: [
        new webpack.BannerPlugin('oreki nice'),
        new webpack.HotModuleReplacementPlugin(),
        new HtmlWebpackPlugin({
            template: 'index.html'
        }),
        new webpack.NamedModulesPlugin(),
        new ExtractTextPlugin('css/[name].css?[contenthash]')
    ]
}